package com.jiayang.hhotel.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.jiayang.hhotel.R;
import com.jiayang.hhotel.bean.CanRentRoomModel;
import com.yanzhenjie.recyclerview.swipe.SwipeMenuAdapter;

import java.util.List;

/**
 * Created by Administrator on 2017/5/16 0016.
 * 可租房列表适配器
 */

    public class CanRentRoomListAdapter extends SwipeMenuAdapter<CanRentRoomListAdapter.ViewHolder> {

    private LayoutInflater inflater;
    private List<CanRentRoomModel.PForcastRoomDtoListBean> mList;
    private Context t;
    public CanRentRoomListAdapter(Context context, List<CanRentRoomModel.PForcastRoomDtoListBean> list){
        this.inflater=LayoutInflater.from(context);
        this.mList=list;
        this.t = context;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        CanRentRoomModel.PForcastRoomDtoListBean model = mList.get(position);
        holder.rmName.setText(model.getDescp());//房间描述
        holder.oneRm.setText(model.getRms1()+t.getString(R.string.between));
        holder.twoRm.setText(model.getRms2()+t.getString(R.string.between));
        holder.threeRm.setText(model.getRms3()+t.getString(R.string.between));
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public int getItemCount() {
        return mList.size();
    }

    @Override
    public View onCreateContentView(ViewGroup parent, int viewType) {
        return inflater.inflate(R.layout.can_rent_room_item,parent,false);
    }

    @Override
    public ViewHolder onCompatCreateViewHolder(View realContentView, int viewType) {
        return new ViewHolder(realContentView);
    }

    class ViewHolder extends RecyclerView.ViewHolder{
        TextView rmName;//房间类型
        TextView oneRm;//第一天可用房数
        TextView twoRm;//第二天可用房数
        TextView threeRm;//第三天可用房数

        public ViewHolder(View convertView) {
            super(convertView);
            rmName= (TextView) convertView.findViewById(R.id.tv_rmName);
            oneRm= (TextView) convertView.findViewById(R.id.tv_one_num);
            twoRm= (TextView) convertView.findViewById(R.id.tv_two_num);
            threeRm= (TextView) convertView.findViewById(R.id.tv_three_num);
        }
    }
}
